#include "dflist.h"
#include "temp_process.h"
#include "humidity_process.h"
#include "tsr_process.h"
#include "subManager.h"
#include "scomm_process.h"
#include "lib/memb.h"

#include <stdio.h>
#include "contiki-net.h"
#include "dev/leds.h"
#include "dev/cc2420.h"
/*
 * create the data buffer.
 */
DFLIST(dflist);
/*
 * create the subscription buffer and list.
 */
LIST(subList);
MEMB(subMemb, struct subManager_item, MAX_SUBSCRIPTION_NUM);

/*
 * create the subscription manager.
 */
struct subManager s_manager;

/*
 * create humidity and temperature sampling process structure.
 */



PROCESS(sapp_process, "boot sensor app");

AUTOSTART_PROCESSES(&sapp_process);

PROCESS_THREAD(sapp_process, ev, data)
{
  PROCESS_BEGIN();
  
  /*
   * initialize the file system which can hold the data.
   */
  dflist_init(dflist);

  s_manager.list = &subList;
  s_manager.memb = &subMemb;

  /*
   * Initialize the humidity and temperature sampling processes.
   */
  temp_process_init(&s_manager);
  humi_process_init(&s_manager);
  tsr_process_init(&s_manager);

  /*
   * start the communication process.
   */
  scomm_process_start(&s_manager, dflist);

  leds_on(LEDS_BLUE);
  leds_on(LEDS_RED);

  printf("power is %d\n", cc2420_get_txpower());
  printf("radio channel is %d\n", cc2420_get_channel());

  PROCESS_END();
}
